using System;
using UnityEngine;

public class MonoTransform : MonoBehaviour
{
    [Serializable]
    public class Vector3Info
    {
        public Transform lTransform;
        public Transform rTransform;
        public Vector3 deltaPosition;
        public float distance;
        public float sqrDistance;
        public float angle;

        public void Calcuate()
        {
            if (lTransform == null || rTransform == null)
            {
                return;
            }

            deltaPosition = lTransform.position - rTransform.position;
            distance = deltaPosition.magnitude;
            sqrDistance = deltaPosition.sqrMagnitude;
            angle = Vector3.Angle(lTransform.forward, rTransform.forward);
        }
    }

    public Vector3 worldPosition;
    public Vector3 localPosition;
    public Vector3 worldEulerAngle;
    public Vector3 localEulerAngle;
    public Vector3 up;
    public Vector3 forward;
    public Vector3 right;

    [HideInInspector]
    public string[] tips;
    
    public Vector3Info[] vector3Infos;

    private void Awake()
    {
        tips = new string[100];
    }

    public void SetTip(string tip, int index = 0)
    {
        tips[index] = tip;
    }

    public void LateUpdate()
    {
        worldPosition = gameObject.transform.position;
        localPosition = gameObject.transform.localPosition;
        worldEulerAngle = gameObject.transform.eulerAngles;
        localEulerAngle = gameObject.transform.localEulerAngles;
        up = gameObject.transform.up;
        forward = gameObject.transform.forward;
        right = gameObject.transform.right;

        if (vector3Infos != null)
        {
            foreach(var vector3Info in vector3Infos)
            {
                vector3Info.Calcuate();
            }
        }
    }
}